import Vue from 'vue'
import Vuex from 'vuex'

import role from './modules/role'
import VueXAlong from 'vuex-along'

Vue.use(Vuex)

const store = new Vuex.Store({
  //全局变量.进行vuex变量封装
  state: {
    // 音频播放ID
    currAudioId: 'none',
    isRecordIng: false,
    keepAlive: true,
    alive: true, //打分页面是否需要缓存
    messageNum: '',
    messageOneNum: '',
    activeEvaluation: null, // 领导评价人员列表信息
    activeNeedId: '', // 领导评价待办id
    stateAlive: true, //缓存页面是否需要刷新 false需要
    pageTab: '1', //跳转页面tab
    pageTabTwo: '',
    bonusTabIndex: '', // 加分项tab
    OfficeBonusTabIndex: 0, // 加分项试点办tab
  },
  mutations: {
    setCurrAudioId(state, payload) {
      state.currAudioId = payload
    },
    setIsRecordIng(state, recordState) {
      state.isRecordIng = recordState
    },
    setMessageNum(state, val) {
      state.messageNum = val
    },
    setMessageOneNum(state, val) {
      state.messageOneNum = val
    },
    setActiveEvaluation(state, val) {
      state.activeEvaluation = val
    },
    setActiveNeedId(state, val) {
      state.activeNeedId = val
    },
  },
  actions: {},
  modules: {},
  getters: {
    messageNum: state => state.messageNum,
    messageOneNum: state => state.messageOneNum,
    activeEvaluation: state => state.activeEvaluation,
    activeNeedId: state => state.activeNeedId,
  },
  plugins: [
    VueXAlong({
      name: 'along', //存放在localStroage或者sessionStroage 中的名字
      local: false, //是否存放在local中  false 不存放 如果存放按照下面session的配置配
      session: { list: [], isFilter: true },
      //如果值不为false 那么可以传递对象 其中 当isFilter设置为true时， list 数组中的值就会被过滤调,这些值不会存放在seesion或者local中
    }),
  ],
  modules: { role },
})
export default store
